#include <iostream>

#include <contact_client.hpp>
using namespace web_contacts;

int main()
{
    ContactClient client;
    while(1)
    {
        cout << "----------网络通讯录客户端----------" << endl;
        cout << "-----------1. 添加联系人------------" << endl;
        cout << "-----------2. 删除联系人------------" << endl;
        cout << "-----------3. 查找联系人------------" << endl;
        cout << "-----------4. 展示全部人------------" << endl;
        cout << "-----------0. 退出通讯录------------" << endl;
        cout << "--->请输入你的选择: ";
        int choice = 0;
        cin >> choice;
        cin.ignore(256, '\n');
        try{
            switch (choice)
            {
            case 0:
                cout << "欢迎下次使用!" << endl;
                return 0;
            case 1:
                client.addContact();
                break;
            case 2:
                client.delContact();
                break;
            case 3:
                client.findOne();
                break;
            case 4:
                client.findAll();
                break;
            default:
                cout << "选择有误, 请重新选择" << endl;
                break;
            }
        }catch(ContactException &exception){
            cout << exception.what() << endl;
        }
    }
}